#include <iostream>
#include <unordered_map>
using namespace std;

const int N = 2e5 + 10;

typedef long long LL;

int a[N];
int n, c;

unordered_map<int, int> mp;

int main()
{
	cin >> n >> c;
	for (int i = 1; i <= n; i++)
	{
		cin >> a[i];
		mp[a[i]]++;
	}
	
	LL ret = 0;
	for (int i = 1; i <= n; i++)
	{
		// c = a[i]
		ret += mp[c + a[i]];
	}
	cout << ret << endl;
	
	return 0;
}
